/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "GEOFT_UNIDADE_FEDERACAO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UnidadeFederacao.findAll", query = "SELECT u FROM UnidadeFederacao u"),
    @NamedQuery(name = "UnidadeFederacao.findByUfdCd", query = "SELECT u FROM UnidadeFederacao u WHERE u.ufdCd = :ufdCd"),
    @NamedQuery(name = "UnidadeFederacao.findByUfdCdIbge", query = "SELECT u FROM UnidadeFederacao u WHERE u.ufdCdIbge = :ufdCdIbge"),
    @NamedQuery(name = "UnidadeFederacao.findByUfdNm", query = "SELECT u FROM UnidadeFederacao u WHERE u.ufdNm = :ufdNm"),
    @NamedQuery(name = "UnidadeFederacao.findByUfdSg", query = "SELECT u FROM UnidadeFederacao u WHERE u.ufdSg = :ufdSg"),
    @NamedQuery(name = "UnidadeFederacao.findByUfdArKm2", query = "SELECT u FROM UnidadeFederacao u WHERE u.ufdArKm2 = :ufdArKm2"),
    @NamedQuery(name = "UnidadeFederacao.findByUfdQtPopulacao", query = "SELECT u FROM UnidadeFederacao u WHERE u.ufdQtPopulacao = :ufdQtPopulacao"),
    @NamedQuery(name = "UnidadeFederacao.findByUfdGmPoligono", query = "SELECT u FROM UnidadeFederacao u WHERE u.ufdGmPoligono = :ufdGmPoligono")})
public class UnidadeFederacao implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "UFD_CD")
    private BigDecimal ufdCd;
    @Size(max = 2)
    @Column(name = "UFD_CD_IBGE")
    private String ufdCdIbge;
    @Size(max = 100)
    @Column(name = "UFD_NM")
    private String ufdNm;
    @Size(max = 5)
    @Column(name = "UFD_SG")
    private String ufdSg;
    @Column(name = "UFD_AR_KM2")
    private BigDecimal ufdArKm2;
    @Column(name = "UFD_QT_POPULACAO")
    private Long ufdQtPopulacao;
    @Size(max = 4000)
    @Column(name = "UFD_GM_POLIGONO")
    private String ufdGmPoligono;
    @OneToMany(mappedBy = "ufdCd")
    private List<Municipio> municipioList;
    @OneToMany(mappedBy = "uslUfdCd")
    private List<UsinaLocalizacao> usinaLocalizacaoList;
    @OneToMany(mappedBy = "orgUfdCd")
    private List<Orgao> orgaoList;
    @JoinColumn(name = "UFD_RPA_CD", referencedColumnName = "PAI_CD")
    @ManyToOne
    private Pais ufdRpaCd;

    /**
     *
     */
    public UnidadeFederacao() {
    }

    /**
     *
     * @param ufdCd
     */
    public UnidadeFederacao(BigDecimal ufdCd) {
        this.ufdCd = ufdCd;
    }

    /**
     *
     * @return
     */
    public BigDecimal getUfdCd() {
        return ufdCd;
    }

    /**
     *
     * @param ufdCd
     */
    public void setUfdCd(BigDecimal ufdCd) {
        this.ufdCd = ufdCd;
    }

    /**
     *
     * @return
     */
    public String getUfdCdIbge() {
        return ufdCdIbge;
    }

    /**
     *
     * @param ufdCdIbge
     */
    public void setUfdCdIbge(String ufdCdIbge) {
        this.ufdCdIbge = ufdCdIbge;
    }

    /**
     *
     * @return
     */
    public String getUfdNm() {
        return ufdNm;
    }

    /**
     *
     * @param ufdNm
     */
    public void setUfdNm(String ufdNm) {
        this.ufdNm = ufdNm;
    }

    /**
     *
     * @return
     */
    public String getUfdSg() {
        return ufdSg;
    }

    /**
     *
     * @param ufdSg
     */
    public void setUfdSg(String ufdSg) {
        this.ufdSg = ufdSg;
    }

    /**
     *
     * @return
     */
    public BigDecimal getUfdArKm2() {
        return ufdArKm2;
    }

    /**
     *
     * @param ufdArKm2
     */
    public void setUfdArKm2(BigDecimal ufdArKm2) {
        this.ufdArKm2 = ufdArKm2;
    }

    /**
     *
     * @return
     */
    public Long getUfdQtPopulacao() {
        return ufdQtPopulacao;
    }

    /**
     *
     * @param ufdQtPopulacao
     */
    public void setUfdQtPopulacao(Long ufdQtPopulacao) {
        this.ufdQtPopulacao = ufdQtPopulacao;
    }

    /**
     *
     * @return
     */
    public String getUfdGmPoligono() {
        return ufdGmPoligono;
    }

    /**
     *
     * @param ufdGmPoligono
     */
    public void setUfdGmPoligono(String ufdGmPoligono) {
        this.ufdGmPoligono = ufdGmPoligono;
    }

    /**
     *
     * @return
     */
    @XmlTransient
    public List<Municipio> getMunicipioList() {
        return municipioList;
    }

    /**
     *
     * @param municipioList
     */
    public void setMunicipioList(List<Municipio> municipioList) {
        this.municipioList = municipioList;
    }

    /**
     *
     * @return
     */
    @XmlTransient
    public List<UsinaLocalizacao> getUsinaLocalizacaoList() {
        return usinaLocalizacaoList;
    }

    /**
     *
     * @param usinaLocalizacaoList
     */
    public void setUsinaLocalizacaoList(List<UsinaLocalizacao> usinaLocalizacaoList) {
        this.usinaLocalizacaoList = usinaLocalizacaoList;
    }

    /**
     *
     * @return
     */
    @XmlTransient
    public List<Orgao> getOrgaoList() {
        return orgaoList;
    }

    /**
     *
     * @param orgaoList
     */
    public void setOrgaoList(List<Orgao> orgaoList) {
        this.orgaoList = orgaoList;
    }

    /**
     *
     * @return
     */
    public Pais getUfdRpaCd() {
        return ufdRpaCd;
    }

    /**
     *
     * @param ufdRpaCd
     */
    public void setUfdRpaCd(Pais ufdRpaCd) {
        this.ufdRpaCd = ufdRpaCd;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ufdCd != null ? ufdCd.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UnidadeFederacao)) {
            return false;
        }
        UnidadeFederacao other = (UnidadeFederacao) object;
        if ((this.ufdCd == null && other.ufdCd != null) || (this.ufdCd != null && !this.ufdCd.equals(other.ufdCd))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.ufdSg;
    }
    
}
